﻿using StreamServeDSIGenerator.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StreamServeDSIGenerator.Business
{
    public class PopulateClass
    {
        public string[,] populateDataTemplate(string[,] destination,int loopTimes, List<DataTemplate>rawDataTemplate, int templatemode)
        {
            List<DataTemplate> tempRawDataTemplate = new List<DataTemplate>();
            tempRawDataTemplate = rawDataTemplate;

            if(templatemode==0)
            {
                int loopRawDataTemplate = 0;
                for (int i = 0; i < loopTimes; i++)
                {
                    destination[i, 0] = tempRawDataTemplate[loopRawDataTemplate].DataTemplateText;
                    loopRawDataTemplate++;
                    if (loopRawDataTemplate >= tempRawDataTemplate.Count)
                    {
                        loopRawDataTemplate = 0;
                    }
                }
            }
            else
            {
                Random rnd = new Random();
                for (int i = 0; i < destination.Length; i++)
                {
                    destination[i, 0] = tempRawDataTemplate[rnd.Next(0,tempRawDataTemplate.Count)].DataTemplateText;
                }
            }

            return destination;
        }
    }
}
